﻿
Imports GUI
Imports DAO
Public Class ucDangKyKhamBenh

    Private Sub pnlDanhSach_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pnlDanhSach.Paint

    End Sub

    Private Sub ucDangKyKhamBenh_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        cbbgioitinh.Items.Add("Nam")
        cbbgioitinh.Items.Add("Nữ")
        'dtpngaykham.Value = Date.Now()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim hoten As String, diachi As String, gioitinh As String
        Dim ngaykham As Date, namsinh As Date
        hoten = txthoten.Text
        diachi = txtdiachi.Text

        gioitinh = cbbgioitinh.SelectedItem
        If (gioitinh = "") Then

            MessageBox.Show("Ban Chua chon gioi tinh")
            Return

        End If
        ngaykham = Date.Now().Date 'dtpngaykham.Value.Date
        namsinh = dtpnamsinh.Value.Date
        Dim dskb_bus As New DanhSachKhamBenhBUS
        Dim thamso_dao As New ThamSoDAO
        Dim kq As Integer, temp As Integer
        kq = dskb_bus.INSERT(hoten, diachi, gioitinh, namsinh, ngaykham)
        temp = thamso_dao.SoLuong()
        If (kq = -1) Then
            MessageBox.Show("Khám tối đa " + temp.ToString() + " bệnh nhân /1 ngày ")
        ElseIf (kq = 0) Then
            MessageBox.Show("Them that bai")
        ElseIf (kq = 1) Then
            MessageBox.Show("Thêm thành công")
        Else
            MessageBox.Show("Dữ liệu lỗi")
        End If

    End Sub
End Class
